package com.guigu.basedservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.basedservice.dto.BaseCarPartsSkuDto;
import com.guigu.basedservice.dto.BasePartsTypeDto;
import com.guigu.basedservice.entity.BasePartsType;
import com.guigu.basedservice.mapper.BasePartsTypeDtoMapper;
import com.guigu.basedservice.mapper.BasePartsTypeMapper;
import com.guigu.basedservice.service.BasePartsTypeDtoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @author heyuhang
 * @create 2024/9/14
 */
@Service
public class BasePartsTypeDtoServiceImpl implements BasePartsTypeDtoService {

    @Autowired(required = false)
    private BasePartsTypeMapper basePartsTypeMapper;

    @Autowired(required = false)
    private BasePartsTypeDtoMapper basePartsTypeDtoMapper;

    @Override
    public List<BasePartsType> getPartsTree() {
        QueryWrapper<BasePartsType> wrapper = new QueryWrapper<>();
        wrapper.eq("PARENT_TYPE_UUID","402881924cbb3aa1014cbbfb0a8f0071");
        List<BasePartsType> basePartsTypes1 = basePartsTypeMapper.selectList(wrapper);
        for (BasePartsType partsType : basePartsTypes1) {
            System.out.println("partsType++++"+partsType);
            BasePartsTypeDto basePartsTypeDto = new BasePartsTypeDto();
            basePartsTypeDto.setCode(partsType.getCode());
            basePartsTypeDto.setName(partsType.getName());
            basePartsTypeDto.setParentTypeUuid(partsType.getParentTypeUuid());
            basePartsTypeDto.setChildren((List<BasePartsTypeDto>) partsType);
            //例外一个条件
            QueryWrapper<BasePartsType> wrapper2 = new QueryWrapper<>();
            wrapper2.like("code", "001___");
            List<BasePartsType> basePartsTypes = basePartsTypeMapper.selectList(wrapper2);
            System.out.println("basePartsTypes++++"+basePartsTypes);
        }
        return basePartsTypes1;
    }

    @Override
    public List<BaseCarPartsSkuDto> findByCondition2(String name) {
        List<BaseCarPartsSkuDto> baseCarPartsSkuDtos = basePartsTypeDtoMapper.findByCondition2(name);
        return baseCarPartsSkuDtos;
    }

}
